
/**
 * Please modify this class to meet your needs
 * This class is not complete
 */

package org.kallsonys.oms.ws.orderservices;

import java.util.logging.Logger;

import org.kallsonnys.oms.dto.OrderDTO;
import org.kallsonnys.oms.dto.TableFilterDTO;
import org.kallsonnys.oms.dto.TableResultDTO;
import org.kallsonnys.oms.services.orders.OrdersFacadeRemote;
import org.kallsonys.oms.commons.locator.ServiceLocator;
import org.kallsonys.oms.ws.mapper.WSMapper;

import com.integration.kallsonys.kallsonysschema.types.DescriptionResponse;
import com.integration.kallsonys.kallsonysschema.types.Order;
import com.integration.kallsonys.kallsonysschema.types.OrderInfoId;
import com.integration.kallsonys.kallsonysschema.types.OrderList;
import com.integration.kallsonys.kallsonysschema.types.PagingDto;

/**
 * This class was generated by Apache CXF 2.6.3
 * 2013-10-29T19:28:19.645-05:00
 * Generated source version: 2.6.3
 * 
 */

@javax.jws.WebService(
                      serviceName = "OrderServices",
                      portName = "OrderServicesSOAP",
                      targetNamespace = "http://ws.oms.kallsonys.org/orderservices",
                      wsdlLocation = "file:/Users/macbook/Documents/BUS-KallsonnysOMS-WS/war/WEB-INF/wsdl/orderServices.wsdl",
                      endpointInterface = "org.kallsonys.oms.ws.orderservices.OrderServices")
                      
public class OrderServicesImpl implements OrderServices {

    private static final Logger logger = Logger.getLogger(OrderServicesImpl.class.getName());

    
    public com.integration.kallsonys.kallsonysschema.types.Order getOrderStatus(com.integration.kallsonys.kallsonysschema.types.Order getOrderStatusRequest) throws GetOrderStatusFault    { 
        logger.info("Executing operation getOrderStatus");
        System.out.println(getOrderStatusRequest);
        try {
            com.integration.kallsonys.kallsonysschema.types.Order _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
        //throw new GetOrderStatusFault("getOrderStatusFault...");
    }

  
    public OrderList getOrders(PagingDto pagingDto) throws GetOrdersFault    { 
        try {
        	
        	logger.info("getOrders:Operation start");
        	
        	OrdersFacadeRemote ordersFacadeRemote = ServiceLocator.getInstance().getRemoteObject("OrdersBean");
        	TableFilterDTO mapTableFilterDTO = WSMapper.mapTableFilterDTO(pagingDto);
			TableResultDTO<OrderDTO> ordersList = ordersFacadeRemote.getOrdersList(mapTableFilterDTO);
        	
			OrderList orderList = WSMapper.mapOrderList(ordersList.getResult());
        	
        	return orderList;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new GetOrdersFault("OCURRIO UN ERROR INESPERADO EN LISTADO DE LAS ORDENES");
        }finally{
        	logger.info("getOrders:Operation finish");
        }
    }

    
    public DescriptionResponse createOrder(Order createOrderRequest) throws CreateOrderFault    { 
        logger.info("Executing operation createOrder");
        System.out.println(createOrderRequest);
        try {
        	
        	logger.info("createOrder:Operation start");
        	
        	OrderDTO orderDTO = WSMapper.mapOrderDTO(createOrderRequest);
        	
        	ServiceLocator.getInstance().sendMsgToQueue(ServiceLocator.ORDERS_ENGINE_QUEUE, null, orderDTO);
        	
        	DescriptionResponse descriptionResponse = new DescriptionResponse();
        	descriptionResponse.setCode("001");
        	descriptionResponse.setDescription("Estamos procesando su orden en unos minutos le informaremos a su correo electornico. Gracias por preferir Kallsonnys ");
            return descriptionResponse;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new CreateOrderFault("OCURRIO UN ERROR INESPERADO EN EL PROCESAMIENTO DE LA ORDEN");
        }finally{
        	logger.info("createOrder:Operation finish");
        }
 
    }

	public Order getOrderDetail(OrderInfoId getOrderDetailRequest) throws GetOrderDetailFault{
	       
	        try {
	        	
	        	logger.info("getOrderDetail:Operation start");
	        	
	        	OrdersFacadeRemote ordersFacadeRemote = ServiceLocator.getInstance().getRemoteObject("OrdersBean");
	        	OrderDTO orderDTO = ordersFacadeRemote.getOrderDetail(Long.parseLong(getOrderDetailRequest.getId()));
	        	
	        	return WSMapper.mapOrder(orderDTO);
	        	
	        } catch (java.lang.Exception ex) {
	            ex.printStackTrace();
	            throw new GetOrderDetailFault("OCURRIO UN ERROR INESPERADO OBTENIENDO EL DETALLE DE LA ORDEN");
	        }finally{
	        	logger.info("getOrderDetail:Operation finish");
	        }
	}

}
